package com.x52im.rainbowchat.http.logic;

import com.alibaba.fastjson.JSON;
import com.eva.framework.Processor;
import com.eva.framework.dto.SysActionConst;
import com.eva.framework.utils.EndsExceptionFactory;
import com.x52im.rainbowchat.http.logic.dto.AlipayCertverifyDTO;
import com.x52im.rainbowchat.http.logic.dto.AlipayDepositDTO;
import com.x52im.rainbowchat.http.logic.pay.alipay.MCertverify;
import com.x52im.rainbowchat.http.logic.pay.alipay.MDeposit;

public class AlipayCertProcessor implements SysActionConst, Processor {

    @Override
    public Object process(int job_dispatch_id, int action_id, Object _newData, Object oldData, User user) throws Exception {
        Object ret = null;
        String newDataJSON = (String) _newData;
        AlipayCertverifyDTO dto = JSON.parseObject(newDataJSON, AlipayCertverifyDTO.class);
        dto.setUserUid(Integer.parseInt(user.getUserUid()));
        switch (job_dispatch_id) {
            case 11: // 实名认证步骤1
                ret = new MCertverify().getVerifyId(dto);
                break;
            case 12: // 实名认证步骤1
                ret = new MCertverify().getAuthStr(dto);
                break;
            case 13: // 实名认证步骤2
                ret = new MCertverify().getAccessTokenByAuthCode(dto, true);
                break;
            case 14: // 实名认证步骤3
                ret = new MCertverify().cert(dto);
                break;
            case 19: // 获取授权(客户端不使用该接口)
                ret = new MCertverify().getAuthCodeByURL(dto);
                break;
            default:
                throw EndsExceptionFactory.INVALID_JOB_DISPATCHER_ID(job_dispatch_id);
        }
        return ret;
    }
}
